
<!DOCTYPE HTML>
<html lang="en" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>schema设计 · InfluxDB中文文档</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="jasper">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-comment/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="storage_engine.html" />
    
    
    <link rel="prev" href="insights_tradeoffs.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://legacy.gitbook.com/book/jasper-zhang1/influxdb" target="_blank" class="custom-link">InfluxDB中文文档</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    前言
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Introduction/">
            
                <a href="../Introduction/">
            
                    
                    介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Introduction/installation.html">
            
                <a href="../Introduction/installation.html">
            
                    
                    安装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../Introduction/getting_start.html">
            
                <a href="../Introduction/getting_start.html">
            
                    
                    入门指南
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../Guide/">
            
                <a href="../Guide/">
            
                    
                    使用指南
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../Guide/writing_data.html">
            
                <a href="../Guide/writing_data.html">
            
                    
                    写入数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.2" data-path="../Guide/querying_data.html">
            
                <a href="../Guide/querying_data.html">
            
                    
                    查询数据
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.3" data-path="../Guide/downsampling_and_retention.html">
            
                <a href="../Guide/downsampling_and_retention.html">
            
                    
                    采样和数据保留
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.4" data-path="../Guide/hardware_sizing.html">
            
                <a href="../Guide/hardware_sizing.html">
            
                    
                    硬件指南
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3.5" data-path="../Guide/https_setup.html">
            
                <a href="../Guide/https_setup.html">
            
                    
                    HTTPS设置
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="./">
            
                <a href="./">
            
                    
                    概念介绍
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="key_concepts.html">
            
                <a href="key_concepts.html">
            
                    
                    关键概念
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="glossary.html">
            
                <a href="glossary.html">
            
                    
                    专业术语
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="crosswalk.html">
            
                <a href="crosswalk.html">
            
                    
                    与SQL比较
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.4" data-path="insights_tradeoffs.html">
            
                <a href="insights_tradeoffs.html">
            
                    
                    InfluxDB的设计见解和权衡
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.4.5" data-path="schema_and_data_layout.html">
            
                <a href="schema_and_data_layout.html">
            
                    
                    schema设计
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.6" data-path="storage_engine.html">
            
                <a href="storage_engine.html">
            
                    
                    存储引擎
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../Write_protocols/">
            
                <a href="../Write_protocols/">
            
                    
                    写入协议
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../Write_protocols/line_protocol.html">
            
                <a href="../Write_protocols/line_protocol.html">
            
                    
                    行协议
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../Query_language/">
            
                <a href="../Query_language/">
            
                    
                    查询语言
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../Query_language/data_exploration.html">
            
                <a href="../Query_language/data_exploration.html">
            
                    
                    数据查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../Query_language/schema_exploration.html">
            
                <a href="../Query_language/schema_exploration.html">
            
                    
                    schema查询语法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../Query_language/database_management.html">
            
                <a href="../Query_language/database_management.html">
            
                    
                    数据库管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../Query_language/continuous_queries.html">
            
                <a href="../Query_language/continuous_queries.html">
            
                    
                    连续查询
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../Query_language/functions.html">
            
                <a href="../Query_language/functions.html">
            
                    
                    函数
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../Query_language/math_operators.html">
            
                <a href="../Query_language/math_operators.html">
            
                    
                    数学运算符
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../Query_language/authentication_and_authorization.html">
            
                <a href="../Query_language/authentication_and_authorization.html">
            
                    
                    认证和授权
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../Troubleshooting/">
            
                <a href="../Troubleshooting/">
            
                    
                    故障排除
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../Troubleshooting/faq.html">
            
                <a href="../Troubleshooting/faq.html">
            
                    
                    FAQ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../Troubleshooting/system_monitor.html">
            
                <a href="../Troubleshooting/system_monitor.html">
            
                    
                    系统监控
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.3" data-path="../Troubleshooting/query_management.html">
            
                <a href="../Troubleshooting/query_management.html">
            
                    
                    查询管理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.4" data-path="../Troubleshooting/error_messages.html">
            
                <a href="../Troubleshooting/error_messages.html">
            
                    
                    错误信息
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >schema设计</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="schema&#x8BBE;&#x8BA1;">schema&#x8BBE;&#x8BA1;</h1>
<p>&#x6BCF;&#x4E2A;InfluxDB&#x7528;&#x4F8B;&#x90FD;&#x53EF;&#x80FD;&#x662F;&#x4E0D;&#x4E00;&#x6837;&#x7684;&#xFF0C;schema&#x5C06;&#x53CD;&#x6620;&#x51FA;&#x8FD9;&#x79CD;&#x72EC;&#x7279;&#x6027;&#x3002; &#x4F46;&#x662F;&#xFF0C;&#x5728;&#x8BBE;&#x8BA1;schema&#x65F6;&#xFF0C;&#x6709;&#x4E00;&#x4E9B;&#x9075;&#x5FAA;&#x7684;&#x4E00;&#x822C;&#x51C6;&#x548C;&#x53EF;&#x4EE5;&#x907F;&#x514D;&#x7684;&#x9677;&#x9631;&#x3002;</p>
<h2 id="&#x4E00;&#x822C;&#x5EFA;&#x8BAE;">&#x4E00;&#x822C;&#x5EFA;&#x8BAE;</h2>
<h3 id="&#x63A8;&#x5D07;&#x7684;schema&#x8BBE;&#x8BA1;">&#x63A8;&#x5D07;&#x7684;schema&#x8BBE;&#x8BA1;</h3>
<p>&#x6CA1;&#x6709;&#x7279;&#x5B9A;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x6211;&#x4EEC;&#x6709;&#x5982;&#x4E0B;&#x5EFA;&#x8BAE;&#xFF1A;</p>
<h4 id="&#x54EA;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#x4F7F;&#x7528;tag">&#x54EA;&#x4E9B;&#x60C5;&#x51B5;&#x4E0B;&#x4F7F;&#x7528;tag</h4>
<p>&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x4F60;&#x7684;&#x67E5;&#x8BE2;&#x53EF;&#x4EE5;&#x6307;&#x5F15;&#x4F60;&#x54EA;&#x4E9B;&#x6570;&#x636E;&#x653E;&#x5728;tag&#x4E2D;&#xFF0C;&#x54EA;&#x4E9B;&#x653E;&#x5728;field&#x4E2D;&#x3002;</p>
<ul>
<li>&#x628A;&#x4F60;&#x7ECF;&#x5E38;&#x67E5;&#x8BE2;&#x7684;&#x5B57;&#x6BB5;&#x4F5C;&#x4E3A;tag</li>
<li>&#x5982;&#x679C;&#x4F60;&#x8981;&#x5BF9;&#x5176;&#x4F7F;&#x7528;<code>GROUP BY()</code>&#xFF0C;&#x4E5F;&#x8981;&#x653E;&#x5728;tag&#x4E2D;</li>
<li>&#x5982;&#x679C;&#x4F60;&#x8981;&#x5BF9;&#x5176;&#x4F7F;&#x7528;InfluxQL&#x51FD;&#x6570;&#xFF0C;&#x5219;&#x5C06;&#x5176;&#x653E;&#x5230;field&#x4E2D;</li>
<li>&#x5982;&#x679C;&#x4F60;&#x9700;&#x8981;&#x5B58;&#x50A8;&#x7684;&#x503C;&#x4E0D;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5219;&#x9700;&#x8981;&#x653E;&#x5230;field&#x4E2D;&#xFF0C;&#x56E0;&#x4E3A;tag value&#x53EA;&#x80FD;&#x662F;&#x5B57;&#x7B26;&#x4E32;</li>
</ul>
<h4 id="&#x907F;&#x514D;influxql&#x4E2D;&#x5173;&#x952E;&#x5B57;&#x4F5C;&#x4E3A;&#x6807;&#x8BC6;&#x7B26;&#x540D;&#x79F0;">&#x907F;&#x514D;InfluxQL&#x4E2D;&#x5173;&#x952E;&#x5B57;&#x4F5C;&#x4E3A;&#x6807;&#x8BC6;&#x7B26;&#x540D;&#x79F0;</h4>
<p>&#x8FD9;&#x4E0D;&#x662F;&#x5FC5;&#x9700;&#x7684;&#xFF0C;&#x4F46;&#x5B83;&#x7B80;&#x5316;&#x4E86;&#x5199;&#x67E5;&#x8BE2;; &#x60A8;&#x4E0D;&#x5FC5;&#x5C06;&#x8FD9;&#x4E9B;&#x6807;&#x8BC6;&#x7B26;&#x5305;&#x88C5;&#x5728;&#x53CC;&#x5F15;&#x53F7;&#x4E2D;&#x3002; &#x6807;&#x8BC6;&#x7B26;&#x6709;database&#x540D;&#x79F0;&#xFF0C;retention policy&#x540D;&#x79F0;&#xFF0C;user&#x540D;&#xFF0C;measurement&#x540D;&#x79F0;&#xFF0C;tag key&#x548C;field key&#x3002;&#x8BF7;&#x53C2;&#x9605;<a href="">InfluxQL&#x5173;&#x952E;&#x8BCD;</a>&#x770B;&#x4E0B;&#x54EA;&#x4E9B;&#x5355;&#x8BCD;&#x9700;&#x8981;&#x88AB;&#x907F;&#x514D;&#x3002;</p>
<p>&#x8BF7;&#x6CE8;&#x610F;&#xFF0C;&#x5982;&#x679C;&#x67E5;&#x8BE2;&#x4E2D;&#x5305;&#x542B;&#x9664;[A-z&#xFF0C;_]&#x4EE5;&#x5916;&#x7684;&#x5B57;&#x7B26;&#xFF0C;&#x5219;&#x8FD8;&#x9700;&#x8981;&#x5C06;&#x5B83;&#x4EEC;&#x7528;&#x53CC;&#x5F15;&#x53F7;&#x62EC;&#x8D77;&#x6765;&#x3002;</p>
<h3 id="&#x907F;&#x514D;&#x7684;schema&#x8BBE;&#x8BA1;">&#x907F;&#x514D;&#x7684;schema&#x8BBE;&#x8BA1;</h3>
<p>&#x6CA1;&#x6709;&#x7279;&#x5B9A;&#x7684;&#x987A;&#x5E8F;&#xFF0C;&#x6211;&#x4EEC;&#x6709;&#x5982;&#x4E0B;&#x5EFA;&#x8BAE;&#xFF1A;</p>
<h4 id="&#x4E0D;&#x8981;&#x6709;&#x592A;&#x591A;&#x7684;series">&#x4E0D;&#x8981;&#x6709;&#x592A;&#x591A;&#x7684;series</h4>
<p>tags&#x5305;&#x542B;&#x9AD8;&#x5EA6;&#x53EF;&#x53D8;&#x7684;&#x4FE1;&#x606F;&#xFF0C;&#x5982;UUID&#xFF0C;&#x54C8;&#x5E0C;&#x503C;&#x548C;&#x968F;&#x673A;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x8FD9;&#x5C06;&#x5BFC;&#x81F4;&#x6570;&#x636E;&#x5E93;&#x4E2D;&#x7684;&#x5927;&#x91CF;measurement&#xFF0C;&#x901A;&#x4FD7;&#x5730;&#x8BF4;&#x662F;&#x9AD8;series cardinality&#x3002;series cardinality&#x9AD8;&#x662F;&#x8BB8;&#x591A;&#x6570;&#x636E;&#x5E93;&#x9AD8;&#x5185;&#x5B58;&#x4F7F;&#x7528;&#x7684;&#x4E3B;&#x8981;&#x539F;&#x56E0;&#x3002;</p>
<p>&#x8BF7;&#x53C2;&#x9605;<a href="../Guide/hardware_sizing.html">&#x786C;&#x4EF6;&#x6307;&#x5357;</a>&#x4E2D;&#x57FA;&#x4E8E;&#x4F60;&#x7684;&#x786C;&#x4EF6;&#x7684;series cardinality&#x7684;&#x5EFA;&#x8BAE;&#x3002;&#x5982;&#x679C;&#x7CFB;&#x7EDF;&#x6709;&#x5185;&#x5B58;&#x9650;&#x5236;&#xFF0C;&#x8BF7;&#x8003;&#x8651;&#x5C06;&#x9AD8;cardinality&#x6570;&#x636E;&#x5B58;&#x50A8;&#x4E3A;field&#x800C;&#x4E0D;&#x662F;tag&#x3002;</p>
<h4 id="&#x5982;&#x4F55;&#x8BBE;&#x8BA1;measurement">&#x5982;&#x4F55;&#x8BBE;&#x8BA1;measurement</h4>
<p>&#x4E00;&#x822C;&#x6765;&#x8BF4;&#xFF0C;&#x8C08;&#x8BBA;&#x8FD9;&#x4E00;&#x6B65;&#x53EF;&#x4EE5;&#x7B80;&#x5316;&#x4F60;&#x7684;&#x67E5;&#x8BE2;&#x3002;InfluxDB&#x7684;&#x67E5;&#x8BE2;&#x4F1A;&#x5408;&#x5E76;&#x5C5E;&#x4E8E;&#x540C;&#x4E00;measurement&#x8303;&#x56F4;&#x5185;&#x7684;&#x6570;&#x636E;; &#x7528;tag&#x533A;&#x5206;&#x6570;&#x636E;&#x6BD4;&#x4F7F;&#x7528;&#x8BE6;&#x7EC6;&#x7684;measurement&#x540D;&#x5B57;&#x66F4;&#x597D;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF1A;&#x8003;&#x8651;&#x5982;&#x4E0B;&#x7684;schema&#xFF1A;</p>
<pre><code>Schema 1 - Data encoded in the measurement name
-------------
blueberries.plot-1.north temp=50.1 1472515200000000000
blueberries.plot-2.midwest temp=49.8 1472515200000000000
</code></pre><p>&#x8FD9;&#x4E2A;&#x6CA1;&#x6709;tag&#x7684;&#x957F;&#x957F;&#x7684;measurement&#x540D;&#x5B57;(<code>blueberries.plot-1.north</code>)&#x6709;&#x4E9B;&#x7C7B;&#x4F3C;&#x4E8E;Graphite&#x7684;metric&#x3002;&#x50CF;<code>plot``region</code>&#x8FD9;&#x6837;&#x7684;&#x4FE1;&#x606F;&#x653E;&#x5728;measurement&#x540D;&#x5B57;&#x91CC;&#x9762;&#x5C06;&#x4F1A;&#x4F7F;&#x6570;&#x636E;&#x5F88;&#x96BE;&#x53BB;&#x67E5;&#x8BE2;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x4F7F;&#x7528;schema 1&#x8BA1;&#x7B97;&#x4E24;&#x4E2A;&#x56FE;1&#x548C;2&#x7684;&#x5E73;&#x5747;<code>temp</code>&#x662F;&#x4E0D;&#x53EF;&#x80FD;&#x7684;&#x3002;&#x5C06;&#x5176;&#x4E0E;&#x5982;&#x4E0B;schema&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF1A;</p>
<pre><code>Schema 2 - Data encoded in tags
-------------
weather_sensor,crop=blueberries,plot=1,region=north temp=50.1 1472515200000000000
weather_sensor,crop=blueberries,plot=2,region=midwest temp=49.8 1472515200000000000
</code></pre><p>&#x4EE5;&#x4E0B;&#x67E5;&#x8BE2;&#x8BA1;&#x7B97;&#x4E86;&#x843D;&#x5728;&#x5317;&#x90E8;&#x5730;&#x533A;&#x7684;&#x84DD;&#x8393;&#x7684;&#x5E73;&#x5747;<code>temp</code>&#x3002; &#x867D;&#x7136;&#x8FD9;&#x4E24;&#x4E2A;&#x67E5;&#x8BE2;&#x90FD;&#x6BD4;&#x8F83;&#x7B80;&#x5355;&#xFF0C;&#x4F46;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x4F7F;&#x5F97;&#x67D0;&#x4E9B;&#x67E5;&#x8BE2;&#x66F4;&#x52A0;&#x590D;&#x6742;&#x6216;&#x6839;&#x672C;&#x4E0D;&#x53EF;&#x80FD;&#x5B9E;&#x73B0;&#x3002;</p>
<pre><code># Schema 1 - Query for data encoded in the measurement name
&gt; SELECT mean(&quot;temp&quot;) FROM /\.north$/

# Schema 2 - Query for data encoded in tags
&gt; SELECT mean(&quot;temp&quot;) FROM &quot;weather_sensor&quot; WHERE &quot;region&quot; = &apos;north&apos;
</code></pre><h4 id="&#x4E0D;&#x8981;&#x628A;&#x591A;&#x6761;&#x4FE1;&#x606F;&#x653E;&#x5230;&#x4E00;&#x4E2A;tag&#x91CC;&#x9762;">&#x4E0D;&#x8981;&#x628A;&#x591A;&#x6761;&#x4FE1;&#x606F;&#x653E;&#x5230;&#x4E00;&#x4E2A;tag&#x91CC;&#x9762;</h4>
<p>&#x4E0E;&#x4E0A;&#x8FF0;&#x76F8;&#x4F3C;&#xFF0C;&#x5C06;&#x5177;&#x6709;&#x591A;&#x6761;&#x4FE1;&#x606F;&#x7684;&#x5355;&#x4E2A;tag&#x62C6;&#x5206;&#x4E3A;&#x591A;&#x4E2A;&#x5355;&#x72EC;&#x7684;tag&#x5C06;&#x7B80;&#x5316;&#x67E5;&#x8BE2;&#x5E76;&#x51CF;&#x5C11;&#x5BF9;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x7684;&#x9700;&#x6C42;&#x3002;</p>
<p>&#x4F8B;&#x5982;&#xFF0C;&#x8003;&#x8651;&#x5982;&#x4E0B;&#x7684;schema&#xFF1A;</p>
<pre><code>Schema 1 - Multiple data encoded in a single tag
-------------
weather_sensor,crop=blueberries,location=plot-1.north temp=50.1 1472515200000000000
weather_sensor,crop=blueberries,location=plot-2.midwest temp=49.8 1472515200000000000
</code></pre><p>&#x4E0A;&#x8FF0;&#x6570;&#x636E;&#x5C06;&#x591A;&#x4E2A;&#x5355;&#x72EC;&#x7684;&#x53C2;&#x6570;<code>plot``region</code>&#x653E;&#x5230;&#x4E86;&#x4E00;&#x4E2A;&#x957F;tag value&#x91CC;&#x9762;&#xFF08;<code>plot-1.north</code>&#xFF09;&#x3002; &#x5C06;&#x5176;&#x4E0E;&#x5982;&#x4E0B;schema&#x8FDB;&#x884C;&#x6BD4;&#x8F83;&#xFF1A;</p>
<pre><code>Schema 2 - Data encoded in multiple tags
-------------
weather_sensor,crop=blueberries,plot=1,region=north temp=50.1 1472515200000000000
weather_sensor,crop=blueberries,plot=2,region=midwest temp=49.8 1472515200000000000
</code></pre><p>&#x4EE5;&#x4E0B;&#x67E5;&#x8BE2;&#x8BA1;&#x7B97;&#x4E86;&#x843D;&#x5728;<code>north</code>&#x5730;&#x533A;&#x7684;&#x84DD;&#x8393;&#x7684;&#x5E73;&#x5747;<code>temp</code>&#x3002; &#x867D;&#x7136;&#x8FD9;&#x4E24;&#x4E2A;&#x67E5;&#x8BE2;&#x90FD;&#x662F;&#x76F8;&#x4F3C;&#x7684;&#xFF0C;&#x4F46;&#x5728;Schema 2&#x4E2D;&#x4F7F;&#x7528;&#x591A;&#x4E2A;tag&#x907F;&#x514D;&#x4E86;&#x4F7F;&#x7528;&#x6B63;&#x5219;&#x8868;&#x8FBE;&#x5F0F;&#x3002;</p>
<pre><code># Schema 1 - Query for multiple data encoded in a single tag
&gt; SELECT mean(&quot;temp&quot;) FROM &quot;weather_sensor&quot; WHERE location =~ /\.north$/

# Schema 2 - Query for data encoded in multiple tags
&gt; SELECT mean(&quot;temp&quot;) FROM &quot;weather_sensor&quot; WHERE region = &apos;north&apos;
</code></pre><h2 id="shard-group&#x7684;&#x4FDD;&#x7559;&#x65F6;&#x95F4;duration&#x7684;&#x7BA1;&#x7406;">shard group&#x7684;&#x4FDD;&#x7559;&#x65F6;&#x95F4;(duration)&#x7684;&#x7BA1;&#x7406;</h2>
<h3 id="shard-group&#x7684;&#x4FDD;&#x7559;&#x65F6;&#x95F4;duration&#x9884;&#x89C8;">shard group&#x7684;&#x4FDD;&#x7559;&#x65F6;&#x95F4;(duration)&#x9884;&#x89C8;</h3>
<p>InfluxDB&#x5C06;&#x6570;&#x636E;&#x5B58;&#x50A8;&#x5728;shard group&#x4E2D;&#x3002;shard group&#x7531;&#x5B58;&#x50A8;&#x7B56;&#x7565;&#xFF08;RP&#xFF09;&#x7BA1;&#x7406;&#xFF0C;&#x5E76;&#x5B58;&#x50A8;&#x5177;&#x6709;&#x7279;&#x5B9A;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x5185;&#x7684;&#x65F6;&#x95F4;&#x6233;&#x7684;&#x6570;&#x636E;&#x3002; &#x8BE5;&#x65F6;&#x95F4;&#x95F4;&#x9694;&#x7684;&#x957F;&#x5EA6;&#x79F0;&#x4E3A;shard group&#x7684;duration&#x3002;</p>
<p>&#x9ED8;&#x8BA4;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;shard group&#x7684;duration&#x662F;&#x7531;RP&#x7684;duration&#x51B3;&#x5B9A;&#xFF1A;</p>
<table>
<thead>
<tr>
<th>RP duration</th>
<th>shard group duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>&lt; 2 days</td>
<td>a hour</td>
</tr>
<tr>
<td>&gt;= 2 days and &lt;= 6 months</td>
<td>1 day</td>
</tr>
<tr>
<td>&gt; 6 months</td>
<td>7 days</td>
</tr>
</tbody>
</table>
<p>&#x5728;&#x6BCF;&#x4E2A;RP&#x4E0A;shard group&#x7684;duration&#x4E5F;&#x662F;&#x53EF;&#x4EE5;&#x914D;&#x7F6E;&#x7684;&#xFF0C;&#x53EF;&#x4EE5;&#x770B;<a href="">Retention Policy&#x7BA1;&#x7406;</a>&#x770B;&#x5982;&#x4F55;&#x914D;&#x7F6E;shard group&#x7684;duration&#x3002;</p>
<h3 id="shard-group&#x7684;duration&#x7684;&#x5EFA;&#x8BAE;">shard group&#x7684;duration&#x7684;&#x5EFA;&#x8BAE;</h3>
<p>&#x901A;&#x5E38;&#xFF0C;&#x8F83;&#x77ED;&#x7684;shard group&#x7684;duration&#x5141;&#x8BB8;&#x7CFB;&#x7EDF;&#x6709;&#x6548;&#x5730;&#x4E22;&#x5F03;&#x6570;&#x636E;&#x3002; &#x5F53;InfluxDB&#x5F3A;&#x5236;&#x6267;&#x884C;RP&#x65F6;&#xFF0C;&#x5B83;&#x4F1A;&#x4E22;&#x5F03;&#x6574;&#x4E2A;shard group&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x5355;&#x4E2A;&#x6570;&#x636E;&#x70B9;&#x3002; &#x4F8B;&#x5982;&#xFF0C;&#x5982;&#x679C;&#x60A8;&#x7684;RP&#x6709;&#x4E00;&#x5929;&#x7684;&#x6301;&#x7EED;&#x65F6;&#x95F4;&#xFF0C;&#x4E00;&#x4E2A;shard group&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x4E3A;&#x4E00;&#x5C0F;&#x65F6;; &#x5219;InfluxDB&#x6BCF;&#x5C0F;&#x65F6;&#x5C06;&#x4E22;&#x5F03;&#x4E00;&#x5C0F;&#x65F6;&#x7684;&#x6570;&#x636E;&#x3002;</p>
<p>&#x5982;&#x679C;&#x60A8;&#x7684;RP&#x7684;&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x5927;&#x4E8E;6&#x4E2A;&#x6708;&#xFF0C;&#x5219;&#x4E0D;&#x9700;&#x8981;&#x5177;&#x6709;&#x8F83;&#x77ED;&#x7684;shard group&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x3002; &#x4E8B;&#x5B9E;&#x4E0A;&#xFF0C;&#x5C06;shard group&#x7684;&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x63D0;&#x9AD8;&#x5230;&#x9ED8;&#x8BA4;&#x7684;&#x4E03;&#x5929;&#x503C;&#x4EE5;&#x4E0A;&#x53EF;&#x4EE5;&#x6539;&#x5584;&#x538B;&#x7F29;&#xFF0C;&#x63D0;&#x9AD8;&#x5199;&#x5165;&#x901F;&#x5EA6;&#xFF0C;&#x5E76;&#x51CF;&#x5C11;&#x6BCF;&#x4E2A;shard group&#x7684;&#x56FA;&#x5B9A;&#x8FED;&#x4EE3;&#x5668;&#x5F00;&#x9500;&#x3002; &#x4F8B;&#x5982;&#xFF0C;50&#x5E74;&#x53CA;&#x4EE5;&#x4E0A;&#x7684;shard group&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x662F;&#x53EF;&#x63A5;&#x53D7;&#x7684;&#x914D;&#x7F6E;&#x3002;</p>
<blockquote>
<p>&#x8BF4;&#x660E;&#xFF1A;&#x5F53;&#x914D;&#x7F6E;shard group&#x7684;duration&#x7684;&#x65F6;&#x5019;&#xFF0C;<code>INF</code>(infinite)&#x662F;&#x4E00;&#x4E2A;&#x4E0D;&#x5408;&#x7406;&#x7684;&#x914D;&#x7F6E;&#x3002;&#x5728;&#x5B9E;&#x9645;&#x5DE5;&#x4F5C;&#x4E2D;&#xFF0C;&#x7279;&#x5B9A;&#x7684;duration<code>1000w</code>&#x5C31;&#x8DB3;&#x591F;&#x8FBE;&#x5230;&#x975E;&#x5E38;&#x957F;&#x7684;shard group&#x6301;&#x7EED;&#x65F6;&#x95F4;&#x3002;</p>
</blockquote>
<p>&#x6211;&#x4EEC;&#x5EFA;&#x8BAE;shard group&#x7684;&#x914D;&#x7F6E;&#x5982;&#x4E0B;&#xFF1A;</p>
<ul>
<li>&#x662F;&#x4F60;&#x4E00;&#x822C;&#x67E5;&#x8BE2;&#x65F6;&#x95F4;&#x8303;&#x56F4;&#x7684;&#x4E24;&#x500D;</li>
<li>&#x6BCF;&#x4E2A;shard group&#x91CC;&#x81F3;&#x5C11;&#x6709;100000&#x4E2A;&#x6570;&#x636E;&#x70B9;</li>
<li>&#x6BCF;&#x4E2A;shard group&#x91CC;&#x9762;&#x7684;&#x6BCF;&#x4E2A;series&#x81F3;&#x5C11;&#x6709;1000&#x4E2A;&#x6570;&#x636E;&#x70B9;</li>
</ul>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="insights_tradeoffs.html" class="navigation navigation-prev " aria-label="Previous page: InfluxDB的设计见解和权衡">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="storage_engine.html" class="navigation navigation-next " aria-label="Next page: 存储引擎">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"schema设计","level":"1.4.5","depth":2,"next":{"title":"存储引擎","level":"1.4.6","depth":2,"path":"Concepts/storage_engine.md","ref":"Concepts/storage_engine.md","articles":[]},"previous":{"title":"InfluxDB的设计见解和权衡","level":"1.4.4","depth":2,"path":"Concepts/insights_tradeoffs.md","ref":"Concepts/insights_tradeoffs.md","articles":[]},"dir":"ltr"},"config":{"plugins":["comment"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"comment":{"highlightCommented":true},"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"github":"jasper-zhang/influxdb-document-cn","theme":"default","author":"jasper","pdf":{"pageNumbers":true,"fontSize":16,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"InfluxDB中文文档","language":"en","links":{"sidebar":{"InfluxDB中文文档":"https://legacy.gitbook.com/book/jasper-zhang1/influxdb"},"gitbook":true},"gitbook":"*","description":""},"file":{"path":"Concepts/schema_and_data_layout.md","mtime":"2019-09-29T09:05:38.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2019-09-29T09:10:37.143Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-comment/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

